﻿#region

using System;
using System.Collections.Generic;
using System.Drawing;
using MediaSage.Lib;
using MediaSage.Lib.Configuration;
using MediaSage.Lib.Database;
using MediaSage.Lib.Utilities;
using Microsoft.VisualStudio.TestTools.UnitTesting;

#endregion

namespace MediaSageLibTest
{
    ///<summary>
    ///    This is a test class for UtilTest and is intended
    ///    to contain all UtilTest Unit Tests
    ///</summary>
    [TestClass]
    public class UtilTest
    {
        #region Fields

        private static Config config;

        #endregion Fields

        #region Properties

        ///<summary>
        ///    Gets or sets the test context which provides
        ///    information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext { get; set; }

        #endregion Properties

        #region Methods

        /// <summary>
        ///     A test for CopyObject with an bool
        /// </summary>
        [TestMethod]
        public void CopyObjectAsBool()
        {
            bool? Input;
            bool CopyObject;
            bool Expected;
            bool Actual;         

            // Test MediaMergeType.OVERWRITE for a bool
            Input = false;
            CopyObject = true;
            Expected = true;

            Actual = (bool) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as bool");

            // Test MediaMergeType.WRITE_IF_LARGER for a bool
            Input = false;
            CopyObject = true;
            Expected = true;

            Actual = (bool) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as bool");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a bool
            Input = null;
            CopyObject = true;
            Expected = true;

            Actual = (bool) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as bool");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a bool
            Input = false;
            CopyObject = true;
            Expected = true;

            Actual = (bool) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as bool");

            // Test MediaMergeType.COPY_NEW for a EMediaType
            Input = false;
            CopyObject = true;
            Expected = true;

            Actual = (bool) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as bool");
        }

        ///<summary>
        ///    A test for CopyObject with DateTime
        ///</summary>
        [TestMethod]
        public void CopyObjectAsDateTimeTest()
        {
            DateTime? Input;
            DateTime CopyObject;
            DateTime Expected;
            DateTime Actual;

            // Test MediaMergeType.OVERWRITE for a DateTime
            Input = new DateTime(2012, 1, 1);
            CopyObject = new DateTime(2012, 2, 1);
            Expected = new DateTime(2012, 2, 1);

            Actual = (DateTime) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as DateTime");

            // Test MediaMergeType.WRITE_IF_LARGER for a DateTime
            Input = new DateTime(2012, 1, 1);
            CopyObject = new DateTime(2012, 2, 1);
            Expected = new DateTime(2012, 2, 1);

            Actual = (DateTime) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGER as DateTime");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a DateTime
            Input = null;
            CopyObject = new DateTime(2012, 2, 1);
            Expected = new DateTime(2012, 2, 1);

            Actual = (DateTime) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as DateTime");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a DateTime as a default value
            Input = new DateTime();
            CopyObject = new DateTime(2012, 2, 1);
            Expected = new DateTime(2012, 2, 1);

            Actual = (DateTime) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual,
                            "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as DateTime as a Default value");

            // Test MediaMergeType.COPY_NEW for DateTime
            Input = DateTime.MinValue;
            CopyObject = new DateTime(2012, 1, 1);
            Expected = new DateTime(2012, 1, 1);
            Actual = (DateTime) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as DateTime as a Default value");
        }

        ///<summary>
        ///    A test for CopyObject with double
        ///</summary>
        [TestMethod]
        public void CopyObjectAsDoubleTest()
        {
            double? Input;
            double CopyObject;
            double Expected;
            double Actual;

            // Test MediaMergeType.OVERWRITE for a double
            Input = 1;
            CopyObject = 2;
            Expected = 2;

            Actual = (double) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as double ");

            // Test MediaMergeType.WRITE_IF_LARGER for a double
            Input = 1;
            CopyObject = 100;
            Expected = 100;

            Actual = (double) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as double ");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a double
            Input = null;
            CopyObject = 100;
            Expected = 100;

            Actual = (double) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as double");

            // Test MediaMergeType.COPY_NEW for a double
            Input = 0;
            CopyObject = 100;
            Expected = 100;

            Actual = (double) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as double");
        }

        /// <summary>
        ///     A test for CopyObject with an EMediaType
        /// </summary>
        [TestMethod]
        public void CopyObjectAsEMediaType()
        {
            EMediaType? Input;
            EMediaType CopyObject;
            EMediaType Expected;
            EMediaType Actual;

            // Test MediaMergeType.OVERWRITE for a EMediaType
            Input = EMediaType.undef;
            CopyObject = EMediaType.TV;
            Expected = EMediaType.TV;

            Actual = (EMediaType) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as EMediaType ");

            // Test MediaMergeType.WRITE_IF_LARGER for a EMediaType
            Input = EMediaType.undef;
            CopyObject = EMediaType.TV;
            Expected = EMediaType.TV;

            Actual = (EMediaType) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as EMediaType ");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a EMediaType
            Input = EMediaType.undef;
            CopyObject = EMediaType.TV;
            Expected = EMediaType.TV;

            Actual = (EMediaType) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as EMediaType");

            // Test MediaMergeType.COPY_NEW for a EMediaType
            Input = EMediaType.undef;
            CopyObject = EMediaType.TV;
            Expected = EMediaType.TV;

            Actual = (EMediaType) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as EMediaType");
        }

        ///<summary>
        ///    A test for CopyObject with float
        ///</summary>
        [TestMethod]
        public void CopyObjectAsFloatTest()
        {
            float? Input;
            float CopyObject;
            float Expected;
            float Actual;

            // Test MediaMergeType.OVERWRITE for a float
            Input = 1;
            CopyObject = 2;
            Expected = 2;

            Actual = (float) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as float ");

            // Test MediaMergeType.WRITE_IF_LARGER for a float
            Input = 1;
            CopyObject = 100;
            Expected = 100;

            Actual = (float) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as float ");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a double
            Input = null;
            CopyObject = 100;
            Expected = 100;

            Actual = (float) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as float");

            // Test MediaMergeType.COPY_NEW for a double
            Input = 0;
            CopyObject = 100;
            Expected = 100;

            Actual = (float) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as float");
        }

        [TestMethod]
        public void CopyObjectAsGUIDTest()
        {
            Guid Source = Guid.NewGuid();
            Guid Dest = Guid.NewGuid();
            Guid Actual;

            Actual = (Guid) Util.CopyObject(Source, Dest, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.OVERWRITE on Guid");

            Dest = Guid.Empty;
            Actual = (Guid) Util.CopyObject(Source, Dest, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGER on Guid");

            Dest = Guid.Empty;
            Actual = (Guid) Util.CopyObject(Source, Dest, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY on Guid");

            Dest = Guid.Empty;
            Actual = (Guid) Util.CopyObject(Source, Dest, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.COPY_NEW on Guid");
        }

        [TestMethod]
        [DeploymentItem(@"MediaTestFiles\ball01.jpg")]
        [DeploymentItem(@"MediaTestFiles\ball02.jpg")]
        public void CopyObjectAsImageTest()
        {
            Image Source = Image.FromFile("ball01.jpg");
            Image Dest = Image.FromFile("ball02.jpg");
            Image Actual = null;
            // Test CopyImage Overwrite
            Actual = (Image) Util.CopyObject(Source, Dest, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.OVERWRITE on Image");

            Actual = null;

            //Test Copy if large
            Actual = (Image) Util.CopyObject(Source, Dest, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Source, Actual, "Failed to copy MediaMergeType.COPY_IF_LARGE on Image");

            // Test Copy if Null

            Source = null;
            Dest = Image.FromFile("ball01.jpg");
            Actual = (Image) Util.CopyObject(Source, Dest, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Dest, Actual,
                            "Failed to copy image using MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY with null image");
        }

        ///<summary>
        ///    A test for CopyObject with Int16
        ///</summary>
        [TestMethod]
        public void CopyObjectAsInt16Test()
        {
            Int16? Input;
            Int16 CopyObject;
            Int16 Expected;
            Int16 Actual;

            // Test MediaMergeType.OVERWRITE for a int
            Input = 1;
            CopyObject = 2;
            Expected = 2;

            Actual = (Int16) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as Int16");

            // Test MediaMergeType.WRITE_IF_LARGER for a int
            Input = 1;
            CopyObject = 100;
            Expected = 100;

            Actual = (Int16) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as Int16");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a int
            Input = null;
            CopyObject = 100;
            Expected = 100;

            Actual = (Int16) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as Int16");

            // Test MediaMergeType.COPY_NEW for a int
            Input = 0;
            CopyObject = 100;
            Expected = 100;

            Actual = (Int16) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as Int16");
        }

        ///<summary>
        ///    A test for CopyObject with Int
        ///</summary>
        [TestMethod]
        public void CopyObjectAsIntTest()
        {
            int? Input;
            int CopyObject;
            int Expected;
            int Actual;

            // Test MediaMergeType.OVERWRITE for a int
            Input = 1;
            CopyObject = 2;
            Expected = 2;

            Actual = (int) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as int");

            // Test MediaMergeType.WRITE_IF_LARGER for a int
            Input = 1;
            CopyObject = 100;
            Expected = 100;

            Actual = (int) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as int");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a int
            Input = null;
            CopyObject = 100;
            Expected = 100;

            Actual = (int) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as int");

            // Test MediaMergeType.COPY_NEW for a int
            Input = 0;
            CopyObject = 100;
            Expected = 100;

            Actual = (int) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as int");
        }

        ///<summary>
        ///    A test for CopyObject with Long
        ///</summary>
        [TestMethod]
        public void CopyObjectAsLongTest()
        {
            long? Input;
            long CopyObject;
            long Expected;
            long Actual;

            // Test MediaMergeType.OVERWRITE for a long
            Input = 1;
            CopyObject = 2;
            Expected = 2;

            Actual = (long) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as long");

            // Test MediaMergeType.WRITE_IF_LARGER for a long
            Input = 1;
            CopyObject = 100;
            Expected = 100;

            Actual = (long) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as long");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a long
            Input = null;
            CopyObject = 100;
            Expected = 100;

            Actual = (long) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as long");

            // Test MediaMergeType.COPY_NEW for a long
            Input = 0;
            CopyObject = 100;
            Expected = 100;

            Actual = (long) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as long");
        }

        ///<summary>
        ///    A test for CopyObject with TimeSpan
        ///</summary>
        [TestMethod]
        public void CopyObjectAsStringListTest()
        {
            // Test MediaMergeType.OVERWRITE for a List<string>
            var SourceList = new List<string>();
            var DestList = new List<string>();
            var ActualList = new List<string>();

            SourceList.Add("1");
            SourceList.Add("2");
            SourceList.Add("3");
            DestList.Add("4");
            DestList.Add("5");
            DestList.Add("6");
            ActualList = (List<string>) Util.CopyObject(SourceList, DestList, MediaMergeType.OVERWRITE);
            Assert.AreEqual(SourceList, ActualList, "Failed to copy MediaMergeType.OVERWRITE as a List<string>");

            ActualList = (List<string>) Util.CopyObject(SourceList, DestList, MediaMergeType.COPY_NEW);
            Assert.AreEqual(ActualList.Count, 6, "Failed to copy MediaMErgeType.COPYNEW as List<string>");

            SourceList.Add("7");
            ActualList = (List<string>) Util.CopyObject(SourceList, DestList, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(SourceList, ActualList, "Failed to copy MediaMergeType.WRITE_IF_LARGER");

            DestList.Clear();
            ActualList =
                (List<string>) Util.CopyObject(SourceList, DestList, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(SourceList, ActualList, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY");

            DestList.Add("4");
            DestList.Add("5");
            DestList.Add("6");

            ActualList =
                (List<string>) Util.CopyObject(SourceList, DestList, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreNotEqual(SourceList, ActualList,
                               "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY, copied when Destination wasnt null or empty");
        }

        ///<summary>
        ///    A test for CopyObject with strings
        ///</summary>
        [TestMethod]
        public void CopyObjectAsStringTest()
        {
            string Input;
            string CopyObject;
            string Expected;
            string Actual;

            // Test MediaMergeType.OVERWRITE for a string
            Input = "Something";
            CopyObject = "Something New";
            Expected = "Something New";

            Actual = (string) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as string");

            // Test MediaMergeType.WRITE_IF_LARGER for a string
            Input = "Something";
            CopyObject = "Something New";
            Expected = "Something New";

            Actual = (string) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGE as string");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a string
            Input = "";
            CopyObject = "Something New";
            Expected = "Something New";

            Actual = (string) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as string");

            // Test MediaMergeType.COPY_NEW for a string
            Input = "";
            CopyObject = "Something New";
            Expected = "Something New";

            Actual = (string) Util.CopyObject(CopyObject, Input, MediaMergeType.COPY_NEW);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as string");
        }

        ///<summary>
        ///    A test for CopyObject with TimeSpan
        ///</summary>
        [TestMethod]
        public void CopyObjectAsTimeSpanTest()
        {
            TimeSpan? Input;
            TimeSpan CopyObject;
            TimeSpan Expected;
            TimeSpan Actual;

            // Test MediaMergeType.OVERWRITE for a TimeSpan
            Input = new TimeSpan(1, 0, 0);
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as TimeSpan");

            // Test MediaMergeType.OVERWRITE for a DateTime
            Input = new TimeSpan(1, 0, 0);
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.OVERWRITE as TimeSpan");

            // Test MediaMergeType.WRITE_IF_LARGER for a DateTime
            Input = new TimeSpan(1, 0, 0);
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_IF_LARGER);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_IF_LARGER as TimeSpan");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a DateTime
            Input = null;
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as TimeSpan");

            // Test MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY for a DateTime as a default value
            Input = new TimeSpan();
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual,
                            "Failed to copy MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY as TimeSpan as a Default value");

            // Test MediaMergeType.COPY_NEW for a TimeSpan as a default value
            Input = TimeSpan.Zero;
            CopyObject = new TimeSpan(2, 0, 0);
            Expected = new TimeSpan(2, 0, 0);

            Actual = (TimeSpan) Util.CopyObject(CopyObject, Input, MediaMergeType.WRITE_ONLY_ON_NULL_OR_EMPTY);
            Assert.AreEqual(Expected, Actual, "Failed to copy MediaMergeType.COPY_NEW as TimeSpan as a Default value");
        }

        [TestMethod]
        public void CopyObjectThrowsNullReferenceException205()
        {
            object o;
            object s0 = new object();
            try
            {
                o = Util.CopyObject((object)null, s0, MediaMergeType.OVERWRITE);
            }
            catch (ArgumentException)
            {
                // Should throw here                   
            }            
        }     


        /// <summary>
        ///     A test for MergeImage
        /// </summary>
        [TestMethod]
        [DeploymentItem(@"MediaTestFiles\ball01.jpg")]
        public void MergeImage()
        {
            ImageEntity Source = ImageUtils.GetImageIDFromFile("ball01.jpg", config);
            Source.URL = "http://correct";
            var Destination = new ImageEntity();
            Destination.Height = 22;
            Destination.ImageFormat = EImageFormat.BMP;
            Destination.ImageSize = EImageSize.mid;
            Destination.URL = "http://notright";
            Destination.Width = 23;

            // Test copy with overwrite
            ImageEntity Result = MediaUtil.MergeImageEntity(Source, Destination, MediaMergeType.OVERWRITE);
            Assert.AreEqual(Source.Height, Result.Height, "Failed to overwrite HEIGHT");
            Assert.AreEqual(Source.ImageFormat, Result.ImageFormat, "Failed to overwrite IMAGEFORMAT");
            Assert.AreEqual(Source.ImageSize, Result.ImageSize, "Failed to overwrite IMAGESIZE");
            Assert.AreEqual(Source.URL, Result.URL, "Failed to overwrite URL");
            Assert.AreEqual(Source.Width, Result.Width, "Failed to overwrite WIDTH");
            Assert.AreEqual(Source.HashCode, Result.HashCode, "Failed to overwrite HASHCODE");
            Assert.AreEqual(Source.Filename, Result.Filename, "Failed to overwrite FILENAME");

            // Test copy
        }

        ///<summary>
        ///    A test for MergePerson
        ///</summary>
        [TestMethod]
        public void MergePerson()
        {
            var SourcePerson = new PersonEntity();
            var DestPerson = new PersonEntity();
        }

        //
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        [TestInitialize]
        public void MyTestInitialize()
        {
            config = new Config();
        }

        #endregion Methods

        #region Other

        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //

        #endregion Other
    }
}